//
//  KKLineChartViewController.swift
//  KKChartViewDemo
//
//  Created by liaozhenming on 2019/11/29.
//  Copyright © 2019 kangcun2019. All rights reserved.
//

import UIKit

class KKLineChartViewController: UIViewController {

    var lineChartView: KKLineChartView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        self.navigationItem.title = "折线图"
        
        let item1 = KKChartDataItem.itemWith(identifier: "", color: UIColor.green, value: 2.0)
        let item2 = KKChartDataItem.itemWith(identifier: "", color: UIColor.yellow, value: 3.0)
        let item3 = KKChartDataItem.itemWith(identifier: "", color: UIColor.red, value: 4.0)
        let item4 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 1.0)
        let item5 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 5.0)
        let item6 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 1.0)
        let item7 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 6.0)
        let item8 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 1.0)
        
        let screenWidth = UIScreen.main.bounds.width
        
        lineChartView = KKLineChartView.init(frame: CGRect.init(x: (screenWidth - 300)/2.0 , y: 120, width: 300, height: 240))
        lineChartView!.arr_chartItems = [item1,item2,item3,item4,item5,item6,item7]
        let sectionItem1 =  KKChartDataSectionItem.itemWith(color: UIColor.orange, subItems: [item1,item2,item3,item4])
        let sectionItem2 =  KKChartDataSectionItem.itemWith(color: UIColor.green, subItems: [item3,item4,item5,item6])
        let sectionItem3 =  KKChartDataSectionItem.itemWith(color: UIColor.red, subItems: [item4,item5,item6,item7])
        let sectionItem4 =  KKChartDataSectionItem.itemWith(color: UIColor.purple, subItems: [item5,item6,item7,item8])
        
//        lineChartView!.arr_chartSectionItems = [sectionItem1,sectionItem2,sectionItem3,sectionItem4]
        self.view.addSubview(lineChartView!)
        lineChartView!.kk_updateChartViewUI()
    }
}
